export function setCookie(key, value, seconds, path = '/') {
  const data = new Date()
  data.setTime(data.getTime() - 8 * 3600 * 1000 + seconds * 1000)
  document.cookie = `${key}=${value};expires=${data};path=${path};`
}

export function getCookie(key) {
  const cookie = document.cookie

  if (cookie === '') {
    return
  }
  const cookieArr = cookie.split('; ')
  for (let i = 0; i < cookieArr.length; i++) {
    let brr = cookieArr[i].split('=')
    if (brr[0] === key) {
      return brr[1]
    }
  }
}

export function delCookie(key, path = '/') {
  setCookie(key, null, -1, path)
}